import { replaceCdn, replaceProd, replaceDev } from './replace-config.js'
import { runBuild } from './build.js'
import { compress, rename, upload, deleteFile } from './dir.js'
import { reqApi } from './api.js'

export const main = async () => {
    console.log('替换cnd加速配置');
    await replaceCdn();

    console.log('替换正式环境');
    await replaceProd();

    console.log('打包生成目录build');
    await runBuild();

    console.log('压缩目录build为web.zip');
    await compress()

    console.log('重命名目录build为目录prod');
    rename()

    console.log('上传目录至阿里云');
    await upload()

    console.log('请求后端接口发布web.zip');
    await reqApi()

    console.log('替换回测试环境');
    await replaceDev();

    console.log('删除目录prod和压缩包web.zip');
    await deleteFile()
}